package prototype

type Cloneable interface {
	Clone() Cloneable
}

type PrototypeManager struct {
	prototypes map[string]Cloneable
}

func NewPrototypeManager() *PrototypeManager {
	return &PrototypeManager{make(map[string]Cloneable)}
}

func (p *PrototypeManager) Set(name string, prototype Cloneable) {
	p.prototypes[name] = prototype
}

func (p *PrototypeManager) Get(name string) Cloneable {
	return p.prototypes[name]
}

type Type1 struct {
	name string
}

func (t *Type1) Clone() Cloneable {
	t1 := *t
	return &t1
}

type Type2 struct {
	age uint8
}

func (t *Type2) Clone() Cloneable {
	return t
}
